<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of soaUsers
 *
 * @author dxx
 */

namespace app\common\model\oms;

use think\Model;

class StoreAuth extends Model {

    protected $table = 'store_auth';
    protected $connection = ['database' => 'oms'];
    
    /**
     * 通过条件查询多条数据
     * @param type $condition
     */
    public function getMulti($condition){
        return $this->where($condition)->column('*');
    }
    
    /**
     * 通过条件获取记录
     * @param type $condition
     */
    public function getStoreAuthByCondition($condition){
        return $this->where($condition)->find();
    }
    
    /*
     * 获取审核通过的门店列表
     * @param type $condition 查询条件
     */

    public function getStoreList($type, $companyId) {
        
        if ($type == 1) {
            //全部门店条件
            $condition= [
                'o_id2' => $companyId
            ];
        } elseif ($type == 2) {
            //自营门店条件
            $condition = [
                'type'  => 2,
                "o_id2" => $companyId
            ];
        } elseif ($type == 3) {
            //授权门店条件
            $condition = [
                'type'  => 1,
                "o_id2" => $companyId
            ];
        }
        
        $list = $this->where($condition)->column('*');
        return array_column($list,'store_id');
    }
    
}
